package com.ly.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.ly.bean.Menu;
import com.ly.mapper.MenuMapper;
import com.ly.mapper.RolesMapper;
import com.ly.service.MenuService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 李岩
 * @date 2021/12/27-13:51
 * @describe
 */
@Component
@Service(interfaceClass = MenuService.class)
public class MenuServiceImpl implements MenuService {
    private final Logger logger= LoggerFactory.getLogger(MenuServiceImpl.class);
    private MenuServiceImpl(){
        System.out.println("MenuServiceImpl   的service层");
    }
    @Autowired
    private RolesMapper rolesMapper;
    @Autowired
    private MenuMapper menuMapper;

    //根据角色id 查询菜单
    @Override
    public List<Menu> findMenuByMap(Map<String,Object> map) throws Exception{
        List<Menu> menuList = menuMapper.findMenuByRid(map);
        return menuList;
    }
    //根据角色id 查询所有菜单
    @Override
    public List<Menu> findAllMenuByRid(Integer roleId) throws Exception {
        return menuMapper.findAllMenuByRid(roleId);
    }
    /**
     * 添加菜单
     */
    @Override
    public void insertSelective(Menu record) throws Exception {
        menuMapper.insertSelective(record);
    }
}
